package com.yixq.soa.service.web.auth;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONObject;


/***
 * 存储用户的登录信息以及权限信息
 * @author kyler.tang
 *
 */
public class UserRealm implements Serializable {
	
	public static final String USER_REALM_KEY = "_$_curr_user_realm";
	
	
	/**
	 * @Fields serialVersionUID : TODO(用一句话描述这个变量表示什么)
	 */
	private static final long serialVersionUID = -1991598826311125492L;

	private Long userId;

	private String userName;
	
	private List<String> permissions = new ArrayList<>();
	
	private List<String> roleList = new ArrayList<>();
	
	/**
	 * 当前用户的扩展信息都放置在此属性中.
	 */
	private JSONObject prop = null;
	
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public List<String> getPermissions() {
		return permissions;
	}
	public void setPermissions(List<String> permissions) {
		this.permissions = permissions;
	}
	
	
	public List<String> getRoleList() {
		return roleList;
	}
	public void setRoleList(List<String> roleList) {
		this.roleList = roleList;
	}
	
	public Long getUserId() {
		return userId;
	}
	public void setUserId(Long userId) {
		this.userId = userId;
	}
	
	/**
	 * 当前用户的扩展信息都放置在此属性中.
	 */
	public JSONObject getProp() {
		if(prop == null){
			prop = new JSONObject();
		}
		
		return prop;
	}
	
	/**
	 * 用于链式调用设置值
	 * @param key
	 * @param obj
	 * @return
	 */
	public JSONObject put(String key,Object obj){
		getProp().put(key, obj);
		return prop;
	}
	
	/**
	 * 当前用户的扩展信息都放置在此属性中.
	 */
	public void setProp(JSONObject prop) {
		this.prop = prop;
	}
	
	
	
}
